from django.conf.urls import patterns, include, url
from django.views.generic import TemplateView
#from gleaning_cooperative.views import HomePageView

from django.conf.urls.defaults import *
from views import index_view
from gleaning_collective import settings


from django.views.generic.simple import direct_to_template
from user_profile.profile import UserRegistrationForm
from registration.views import register
from user_profile import views

#import reporting


# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
#reporting.autodiscover()  

# import the logging library
import logging

# Get an instance of a logger
logger = logging.getLogger(__name__)

import sys
sys.path.append("..")

from filebrowser.sites import site

"""
import cal
from cal.views import main
from cal import views
from cal.views import month
"""

urlpatterns = patterns('',

    url(r'^tinymce/', include('tinymce.urls')),
    
    url( r'^grappelli/', include('grappelli.urls') ),
    url(r'^admin/filebrowser/', include(site.urls)),
    # Uncomment the admin/doc line below to enable admin documentation:
    url(r'^admin/doc/', include('django.contrib.admindocs.urls')),

    # Uncomment the next line to enable the admin:
    url(r'^admin/', include(admin.site.urls)),
    url(r'^admin/*', include(admin.site.urls)),
    #url(r'^js/(?P<path>.*)$', 'django.views.static.serve', { 'document_root' : '/static/js/' }) ,
	
	# Django-Register urls
    url(r'^accounts/register/$', register, {'backend': 'user_profile.regbackend.RegBackend','form_class': UserRegistrationForm}, name='registration_register'),
	url(r'^accounts/*', include('registration.backends.default.urls')),
     
    
    #url(r'^go/profile/$', views.profile_list, name="profile"),
	#url(r'^go/profile/edit/$', views.profile_edit, name="profile-edit"),	
    #url(r'^reporting/', include('reporting.urls')),
    #url(r'^go/profile/$', views.profile_list, name="profile"),
    #url('^go/profile/$', direct_to_template, {'template': 'profile.html'}, name="profile"),
    #url(r'^go/profile/$', views.profile_list, name="profile"),
	#url(r'^go/profile/edit/$', views.profile_edit, name="profile-edit"),	

    #'cal.views',
    url(r"^calendar/month/(\d+)/(\d+)/(prev|next)/$", "cal.views.month", name='month'),
    url(r"^calendar/month/(\d+)/(\d+)/$", "cal.views.month", name='month'),
    url(r"^calendar/month$", "cal.views.month", name='month'),
    url(r"^calendar/day/(\d+)/(\d+)/(\d+)/$", "cal.views.day", name='day'),
    url(r"^calendar/settings/*", "cal.views.settings", name='settings'),
    url(r'^calendar/(\d+)/$', 'cal.views.main', name='main'),
    url(r'^calendar/', 'cal.views.month', name='month'),
    
    url(r'^go/profile/$', direct_to_template, {'template': 'profile.html'}, name="profile"),	
    #url(r'^go/profile/$', "cal.views.main", name='main'),
   
    url(r'^mailing/', include('emencia.django.newsletter.urls.mailing_list')),
    url(r'^tracking/', include('emencia.django.newsletter.urls.tracking')),
    #url(r'^newsletters/tracking/calendar/(?P<name>\w+)/', 'cal.views.main'), # this catches the redirect from the newsletter
     url(r'^newsletters/tracking/calendar/(?P<name>\w+)/', 'cal.views.month'),
    url(r'^statistics/', include('emencia.django.newsletter.urls.statistics')),
    url(r'^newsletters/', include('emencia.django.newsletter.urls')),

    (r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT, 'show_indexes': True}),
    (r'^$', 'django.views.static.serve', {'document_root': settings.STATIC_ROOT, 'show_indexes': True}),
    #url(r'^farmer/edit/$', 'gleaning_collective.views.farmer_edit', name='farmer_edit'),
    #url(r'^farmer/$', 'gleaning_collective.views.farmer_view', name='farmer_view'),
    url(r'^mainview/$', 'gleaning_collective.views.main_view', name='main_view'),
    #url(r'^$', 'gleaning_collective.views.index_view', name='index_view'),
    
)
